package com.market.plus.core.domain;

import com.market.plus.core.exception.ExceptionCode;
import com.market.plus.core.exception.TypeCodeException;
import com.market.plus.core.exception.UnsupportTypeException;

public enum NewsType {
   PERSONAL(0), TRIBENEWS(1), PRODUCT(2), NEWS(3);

   private int newsType;

   public int getNewsType() {
      return newsType;
   }

   private NewsType(int newsType) {
      this.newsType = newsType;
   }

   public static NewsType getNewsType(int newsType) throws UnsupportTypeException {
      NewsType value = null;
      switch (newsType) {
      case 0:
         value = PERSONAL;
         break;
      case 1:
         value = TRIBENEWS;
         break;
      case 2:
         value = PRODUCT;
         break;
      case 3:
         value = NEWS;
         break;
      default:
    	 throw new UnsupportTypeException(ExceptionCode.instance(TypeCodeException.class, TypeCodeException.NEWSTYPE));
      }
      return value;
   }
}
